/**
 * Created by apple on 17/3/13.
 */

var mysqlp = require('promise-mysql');
var config = require('./config')
var pool = mysqlp.createPool(config);


var orm=module.exports={};

orm.totalCount = async  function(sql,params){
    let res= await pool.query(sql,params);
    pool.releaseConnection();
    return res;

}
orm.createConn = async function () {
    let conn= await pool.getConnection();
    return conn
};

orm.query= async function(name,obj){
    let conn=orm.createConn();
    let res= await conn.query('select * from medicines',{});
    pool.releaseConnection(conn);
    return res;
};